package com.enfi.api.modules.ext.jpush;

import cn.jpush.api.JPushClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

/**
 * @author wind
 * @date 2020/3/12
 */
@Configuration
public class JPushConfig {

    @Value("${sys.push.appkey:}")
    private String appkey;
    @Value("${sys.push.secret:}")
    private String secret;
    @Value("${sys.push.apns:false}")
    private boolean apns;

    private JPushClient jPushClient;


    /**
     * 推送客户端
     * @return
     */
    @PostConstruct
    public void initJPushClient() {
        jPushClient = new JPushClient(secret, appkey);
    }

    /**
     * 获取推送客户端
     * @return
     */
    public JPushClient getJPushClient() {
        return jPushClient;
    }

    /**
     * 区分开发和线上环境
     * @return
     */
    public boolean getApns() {
        return apns;
    }

    public void setjPushClient(JPushClient jPushClient) {
        this.jPushClient = jPushClient;
    }
}
